
    <div class="content margin_top">
        <header class="header fixed_top bg_mx_green"></header>
        <form class="user"></form>
    </div>
    <!-- toast模版 -->
    <script type="text/template" charset="utf-8" id='toast_template'>
        <i class="iconfont icon-toast{{=it.icon}}"></i>
        <div class="toast_text">{{=it.text}}</div>
    </script>
    <script type="text/template" charset="utf-8" id='info_template'>
        <div class="bg_white">
            <div class="padding_15 flex border_b">
                <div class="width_100">姓名</div>
                <div class="left_100">
                    <input type="text" name="name" value="{{=it.name||''}}" placeholder="请填入姓名" request title="姓名">
                </div>
            </div>
            <div class="padding_15 flex border_b">
                <div class="width_100">性别</div>
                <div class="left_100">
                    <select name="gender" id="gender">
                        <option value="男" {{if(it.gender=='男'){}}selected{{}}}>男</option>
                        <option value="女" {{if(it.gender=='女'){}}selected{{}}}>女</option>
                    </select>
                </div>
            </div>
            <div class="padding_15 flex border_b">
                <div class="width_100">简介</div>
                <div class="left_100">
                    <textarea name="descripation" placeholder="请填入简介" request title="简介">{{=it.descripation||''}}</textarea>
                </div>
            </div>
            <div class="padding_15 flex border_b">
                <div class="width_100">手机号</div>
                <div class="left_200">
                    <input type="text" name="tel" value="{{=it.tel||''}}" placeholder="请填入手机号" request title="手机号" data-pattern="^(0|86|17951)?(13\d|15[0-35-9]|17[678]|18\d|14[57])\d{8}$" data-tips="11位手机号">
                </div>
                <!--<div class="width_100 border_l text_center" onclick="get_code()">发送验证码</div>-->
            </div>
            <!--<div class="padding_15 flex border_b">-->
                <!--<div class="width_100">验证码</div>-->
                <!--<div class="left_100">-->
                    <!--<input type="text" name="code" value="" placeholder="请填入验证码" request title="验证码">-->
                <!--</div>-->
            <!--</div>-->
        </div>

        <input name="_csrf" type="hidden" id="_csrf" value="<{$app->request->csrfToken}>">
        <div class="padding_15 font_16">
            <button class="btn btn_mx_green all_width lineheight_3">保存</button>
        </div>
    </script>
    <script>
        // 页面初始化
            var info = <{$userinfo}>;console.log(info)
            var evalinfo = doT.template($("#info_template").text());
            var evalToast = doT.template($("#toast_template").text());
            loaddata(".user",evalinfo,info);
            loadheadbar("个人资料");
        // 获取验证码
            var got = false;
            function get_code(){
                var tel = $("input[name='tel']").val();
                if(got) return false;
                $.post("",data,function(res){
                    got = true;
                    toast("attention",res.msg);
                    if(res.status == 0){
                        
                    }
                },"json");
            }
        // 提交表单
            var submited = false;
            $(".user").submit(function(e){
                e.preventDefault();
                with(this){
                    for (var i = 0; i < this.length; i++) {
                        if($(this[i]).attr("request")==""){
                            if(!checkone(this[i])){
                                return false;
                            }
                        }
                    }
                    if(submited) return false;
                    var data = $(".user").serialize();
                    $.post("/business/person/post-userinfo",data,function(res){
                        toast("attention",res.msg);
                        submited = true;
                        if(res.status == 0){
                            window.location.href = res.url
                        }
                    },"json");
                }
            })
    </script>


